package com.ruoyi.material.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.material.domain.MateProductDetail;
import com.ruoyi.material.mapper.DetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author
 * @Version 1.0
 */
@RestController
@RequestMapping("/productdetail")
public class ProductDetailController  extends BaseController {
    @Autowired
    DetailMapper detailMapper;


    /*
      全部的采购物资分类明细表
       */
    @GetMapping("/selectProductdetail")
    public TableDataInfo selectProductdetail(@RequestParam(value = "beginTime", required = false) String beginTime,
                                             @RequestParam(value = "endTime", required = false) String endTime) {
        startPage();
        MateProductDetail mateProductDetail=new MateProductDetail();
        mateProductDetail.setBeginTime(beginTime);
        mateProductDetail.setEndTime(endTime);
        mateProductDetail.setDeptId(SecurityUtils.getDeptId());

        List<MateProductDetail> productDetails = detailMapper.selectMateProductDetails(mateProductDetail);
        return getDataTable(productDetails);
    }

    /*
查询已经做完的采购物资分类明细表
     */
    @GetMapping("/selectEdit")
    public Map<String, Object> selectEdit(@RequestParam(value = "detailId", required = false) Long detailId) {
        Map<String, Object> result = new HashMap<>();
        MateProductDetail mateProductDetail = detailMapper.selectProductDetail(detailId);
        result.put("mateProductDetail", mateProductDetail);
        return result;
    }


}
